#pragma once
#include <string>
#include <log_format.h>
#include <log_output.h>

enum class XLog
{
    // 日志级别

    DEBUG,
    INFO,
    ERROR,
    FATAL
};

class Logger
{
private:
    LogFormat *format_{nullptr};
    LogOutput *out_{nullptr};

    XLog log_level_{XLog::DEBUG};

public:
    Logger();
    ~Logger();

    void Write(
        XLog level,
        const std::string &log,
        const std::string &file,
        int line);

    void SetFormat(LogFormat *format)
    {
        if (format_ != nullptr)
        {
            delete format_;
            format_ = nullptr;
        }

        format_ = format;
    };

    void SetOutput(LogOutput *out)
    {
        if (out_ != nullptr)
        {
            delete out_;
            out_ = nullptr;
        }

        out_ = out;
    };

    void SetLevel(XLog level){
        log_level_ = level;
    }
};
